<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="format-detection" content="telephone=no" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	<script type="text/javascript" src="static/admin/js/jquery-3.2.1.min.js"></script>
	<script type="text/javascript" src="static/admin/js/rem.js"></script>
	<link rel="stylesheet" href="static/admin/css/index.css" />
	<link rel="stylesheet" href="static/admin/css/icon/iconfont.css" />
	<title>物业缴费</title>
</head>

<body>
	<div class="white">
		<div class="header">
			<span>{$community_name}</span>
			<!-- <span>早早科技停车场</span> -->
		</div>
		<div class="much">
				{$bill_entry_amount_sum}元
		</div>
		<p style="font-size:18px; text-align: center;line-height: 30px;">待付款</p>
		<div class="content">
			<div class="c-top">
				<ul class="t-name">
					<li>完整门牌号</li>
					<li>业主姓名</li>
				</ul>
				<ul class="t-much">
					<li>{$address}</li>
					<li>{$owner_name}</li>
				</ul>
			</div>
			<div class="c-bottom">
			<p style="font-size:18px; line-height: 30px;">账单明细</p>
				<ul class="t-name">
					{foreach $acct_period as $period}
						<li>{$period}</li>
					{/foreach}
				</ul>
				<ul class="t-zhong">
					{foreach $cost_type as $type}
						<li>{$type}</li>
					{/foreach}
				</ul>
				<ul class="t-much">
					{foreach $bill_entry_amount as $amount}
						<li>{$amount}元</li>
					{/foreach}
				</ul>
			</div>
		</div>
	</div>
	<div class="footer">
		<!-- <p><i class="iconfont layui-extend-gantanhao"></i>请于付款后15分钟内离场，超时将加收停车费</p> -->
		<button><span onclick="wxorder('{$id}', '{$openid}')">立即付款</span></button>
	</div>


<script>
	function wxorder(id,openid){
		var url = '{:url("admin/Bill/wxorder")}'
		$.get(url, {id: id,openid: openid}, function(r){
			// console.log(r,true);return
			if (r.jsApiParameters) {
				onBridgeReady(r.jsApiParameters)
			}else{
				location.reload()
			}
		})
	}

	function onBridgeReady(jsApiParameters){
		var jsApiParameters = eval('(' + jsApiParameters + ')');
		WeixinJSBridge.invoke(
				'getBrandWCPayRequest',{
				"appId":jsApiParameters['appId'],//公众号名称，由商户传入
				"timeStamp":jsApiParameters['timeStamp'],//时间戳，自1970年以来的秒数
				"nonceStr":jsApiParameters['nonceStr'], //随机串
				"package":jsApiParameters['package'],//预支付交易会话标识
				"signType":jsApiParameters['signType'],//微信签名方式：
				"paySign":jsApiParameters['paySign']//微信签名
			},
			//上面参数一定要按照一定的顺序排列，否则会出错（签名验证失败）
			function(res) {
				//前端接收到支付结果通知，get_brand_wcpay_request:ok，支付成功
				//（但是不一定就是真的成功了，一切以回调地址中的结果为准，前端接收到支付通知后只做跳转，不做任何处理）
				//商户订单处理（更新用户账号余额）要放在回调地址中处理
				if(res.err_msg == "get_brand_wcpay_request:ok" ){
					//支付成功，跳转到其他页面
					location.href=header_url+'admin/Bill/billList';
				}
			}
		);
	}
	if (typeof WeixinJSBridge == "undefined"){
		if( document.addEventListener ){
			document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
		}else if (document.attachEvent){
			document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
			document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
		}
	}else{
		onBridgeReady();
	}
</script>
</body>

</html>